<?php
// ----------------------------------------------------------
// * @Copyright @ 2011-2020 By HuaXiaXinCai
// ----------------------------------------------------------
// * @Author Yang Changwu<800334@qq.com> 2016-12-12
// ----------------------------------------------------------
namespace Controller;
use \GatewayWorker\Lib\Gateway;
use \Controller\Core;

class Ranking extends Core{
    //获取投注中奖排行
    public function Award($data,$client_id){
        if(!isset($data['page'])) $data['page'] = 1;
        if(!isset($data['pagesize'])) $data['pagesize'] = 10;
        //$ranking = $this->db->select('username,winmoney')->from('sz_betorder')->setPaging($data['pagesize'])->page($data['page'])->orderByASC(array('winmoney'),false)->query();
        $rankingsql = "SELECT b.nickname as username,a.winmoney FROM `sz_betorder` as a JOIN sz_user as b where a.username = b.username order by a.winmoney desc LIMIT 10";
        $ranking = $this->db->query($rankingsql);
        $rankingcount = $this->db->select('count(*) as count')->from('sz_betorder')->where('winmoney>0')->row();
        $msg = [
            'method' => 'Award',
            'count' => $rankingcount['count'],
            'page' => $data['page'],
            'data' => $ranking,
        ];
        return self::SendMsg(1001,$msg);
    }
}